home *** CD-ROM | disk | FTP | other *** search
/ Isometric Game Programming with DirectX 7.0 / Isometric Game Programming.iso / directx / dxf / doc / directx8 / directx8_c.chm / ds / js / glossary.js < prev    next >
Encoding:
Text File  |  2000-10-17  |  3.3 KB  |  111 lines

  1. window.self.document.writeln('<DIV ID="bufferGLS" STYLE="DISPLAY: none"><OBJECT ID="objectGLS" STYLE="width:1; height:1;" TYPE=TEXT/X-SCRIPTLET></OBJECT></DIV>');
  2.  
  3. window.self.document.writeln('<SCR' + 'IPT LANGUAGE="JSCRIPT" FOR="objectGLS" EVENT="onscriptletevent(event, obj)">if (event == "evt_DocComplete") GetHTMLData(); </SCR' + 'IPT>')
  4.  
  5. window.self.document.writeln('<DIV ID="displayGLS" STYLE="z-index:100; position:absolute; display:none ; width:400px; padding:3px; background-color:lemonchiffon; border-style: inset; border-left-width: 1;  border-top-width: 1;  border-right-width: 2;  border-bottom-width: 2; border-right-color: black; border-bottom-color: black; font:8pt Tahoma; line-height:8pt;"></DIV>');
  6.  
  7. function GlossaryObject(sFileName,sDataID,oSrc, sWordEntry){
  8.     this.sFileName     = sFileName;
  9.     this.sDataID    = sDataID;
  10.     this.oSrc        = oSrc;
  11.     this.sWordEntry = sWordEntry;
  12. }
  13.  
  14. var glbGlossary = new GlossaryObject();
  15.  
  16. function Glossary(oSrc){
  17.     
  18.     glbGlossary.oSrc        = oSrc;    
  19.     glbGlossary.sDataID     = oSrc.DATAID;
  20.     SetGlossaryPositionToClientPos();
  21.  
  22.     if(glbGlossary.sFileName != oSrc.FILENAME){
  23.         var sObject     =  '<OBJECT ID=\"objectGLS" TYPE="text/x-scriptlet" STYLE="DISPLAY: none; WIDTH : 0 ; HEIGHT: 0 ">\n';
  24.             sObject     += '<PARAM NAME="url" VALUE="' + oSrc.FILENAME + '">\n';
  25.             sObject     += '</OBJECT>\n';
  26.             bufferGLS.innerHTML     = sObject;    
  27.     }
  28.     else
  29.         GetHTMLData();
  30.         
  31.     glbGlossary.sFileName     = oSrc.FILENAME;
  32. }
  33.  
  34. function GetHTMLData(){
  35.  
  36.     if(glbGlossary.oSrc.DSPTITLE){
  37.         var str = glbGlossary.oSrc.DSPTITLE;
  38.     }
  39.     else{
  40.         var str = ReplaceCh(glbGlossary.sDataID, '_', ' ');
  41.     };
  42.     glbGlossary.sWordEntry = '<B>' + str + '</B><BR>' + objectGLS.getInnerHTML('GLS_' + glbGlossary.sDataID);
  43.     
  44.     SetGlossaryDisplay(1);
  45. }
  46.  
  47. function ReplaceCh(str, ch_old, ch_new){
  48.     var i;
  49.     var str_new = '';
  50.     var ch;
  51.     
  52.     for(i=0; i<str.length; i++){
  53.         ch = str.charAt(i);
  54.         if (ch == ch_old)
  55.             str_new += ch_new;
  56.         else
  57.             str_new += ch;
  58.     }
  59.     return str_new;
  60. }
  61.  
  62. function SetGlossaryPositionToClientPos(){
  63.     var offSetLeft     = window.event.clientX + document.body.scrollLeft + 10 ;
  64.     var offSetTop    = window.event.clientY + document.body.scrollTop + 10;
  65.     
  66.     // avoid runing to the right of the screen
  67.     if (((offSetLeft + 430) > document.body.offsetWidth) && (document.body.offsetWidth > 430 )) {
  68.             //offSetLeft     = document.body.offsetWidth - 430; displayGLS
  69.             offSetLeft     = document.body.offsetWidth - parseInt(displayGLS.style.width) - 34 ;
  70.         //alert(displayGLS.style.width);
  71.         }
  72.  
  73.     displayGLS.style.left     = offSetLeft;
  74.           displayGLS.style.top     = offSetTop;
  75.     }
  76.  
  77. function SetGlossaryDisplay(nState){
  78.  
  79.     if(nState == 0){
  80.         displayGLS.style.display = "none";
  81.     }
  82.         
  83.     if(nState == 1){
  84.         displayGLS.innerHTML    = glbGlossary.sWordEntry;
  85.         displayGLS.style.display     = "";
  86.         //displayGLS.focus();
  87.         ClearBuffer();
  88.     }
  89. }
  90.  
  91. function ClearBuffer(){
  92.     if(bufferGLS.innerHTML != "<BR>"){
  93.         setTimeout("bufferGLS.innerHTML = '<BR>'", 100)
  94.         glbGlossary.sFileName = " ";
  95.         
  96.     }
  97. }
  98.  
  99. function SetGlossary(){
  100.     ClearBuffer();
  101. }
  102.  
  103. function window.document.onclick(){
  104.     if( typeof(bufferGLS) != "undefined" && window.event.srcElement.className != "Glossary" )
  105.         SetGlossaryDisplay(0);
  106. }
  107.  
  108. function glossOnResize(){
  109.     if( typeof(bufferGLS) != "undefined")
  110.         SetGlossaryDisplay(0);
  111. }